<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/common/taglibs.jsp" %>
<html>
<head>
    <title>提交作业</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <jsp:include page="/WEB-INF/views/common/include_css.jsp"/>
</head>
<body>


<form id="editForm" method="post" class="center-block wd-form-edit">
    <input type="hidden" id="id" name="id" value="${homeworkDetail.id}"/>
    <input type="hidden" id="homeworkId" name="homeworkId" value="${homeworkDetail.homeworkId}"/>
    <input type="hidden" id="commitStatus" name="commitStatus" value="${homeworkDetail.commitStatus}"/>

    <div class="easyui-panel" title="老师布置的作业" style="width:100%;padding: 5px;">
        <div style="margin-top:10px">
            <lable>标题:</lable>
            <lable style="font-size: large">${homework.title}</lable>
        </div>
        <div style="margin-top:10px">
            ${homework.content}
            <%--<textarea id="homeworkContent" style="width:100%;height: 300px;">${homework.content}</textarea>--%>
        </div>
        <div>
            <c:if test="${homework.filename != null && homework.filename != '' }">
                <div>
                    <a href="${ctx}/study/homework/downloadFile?id=${homework.id}">${homework.filename}</a>
                </div>
            </c:if>
        </div>
    </div>
    <div style="margin-top: 10px;"></div>
    <div class="easyui-panel" title="我的作业" style="width:100%;padding: 5px;">
        <div style="margin-top:10px">
            <input class="easyui-textbox" name="title" value="${homeworkDetail.title}" style="width:100%"
                   data-options="label:'标题:',required:true,validType:'maxLength[100]'">
        </div>
        <div style="margin-top:10px">
                <textarea id="homeworkDetailContent" name="content"
                          style="width:100%;height: 300px;">${homeworkDetail.content}</textarea>
        </div>
        <div style="margin-top:10px">
            <%--只有未提交状态才能编辑--%>
            <c:if test="${homeworkDetail.commitStatus == null || homeworkDetail.commitStatus == '0'}">
                <input type="button" value="选择文件" id="selectFileButton"
                       class="btn btn-primary btn-xs js-addShow js-editShow"/>
            </c:if>
            <div id="fileListDiv" style="">
                <c:if test="${homeworkDetail.filename != null && homeworkDetail.filename != '' }">
                    <div>
                        <a href="${ctx}/study/homeworkDetail/downloadFile?id=${homeworkDetail.id}">${homeworkDetail.filename}</a>
                        <c:if test="${homeworkDetail.commitStatus == null || homeworkDetail.commitStatus == '0'}">
                            <a href="javascript:;" class="btn btn-danger btn-xs js-delFile js-addShow js-editShow"
                               style="margin-left: 10px;" data-id="${homeworkDetail.id}">
                                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                                删除文件</a>
                        </c:if>
                    </div>
                </c:if>
            </div>
        </div>
        <div style="text-align:center;margin-top:10px;">
            <%-- commitStatus 提交状态：0：未提交（草稿状态）、1：已提交 --%>
            <c:choose>
                <c:when test="${homeworkDetail.commitStatus == null || homeworkDetail.commitStatus == '0'}">
                    <a id="editButton" href="javascript:void(0);"
                       class="btn btn-default btn-sm js-addShow js-editShow">
                        <span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
                        保存草稿</a>
                    <a id="commitButton" href="javascript:void(0);"
                       class="btn btn-primary btn-sm js-addShow js-editShow" style="margin-left: 10px;">
                        <span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span>
                        提交作业</a>
                </c:when>
                <c:when test="${homeworkDetail.commitStatus == '1'}">
                    <a id="cancelCommitButton" href="javascript:void(0);"
                       class="btn btn-danger btn-sm js-addShow js-editShow" style="margin-left: 10px;">
                        撤销提交</a>
                </c:when>
            </c:choose>
        </div>
    </div>
</form>
<script type="text/html" id="delFileTemplate">
    <div>
        <a href="${ctx}/study/homeworkDetail/downloadFile?id={{id}}">{{filename}}</a>
        <a href="javascript:;" class="btn btn-danger btn-xs js-delFile js-addShow js-editShow"
           style="margin-left: 10px;" data-id="{{id}}">
            <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
            删除文件</a>
    </div>
</script>
<jsp:include page="/WEB-INF/views/common/include_javascript.jsp"/>
<script>
    var pageType = '${pageType}';
</script>
<script src="${ctx}/static/js/homework/homework_detail_edit.js"></script>
</body>
</html>
